#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
from django.core.management.commands.runserver import Command as run


def main():
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings.conf_web')
    try:
        from django.core.management import execute_from_command_line
    except ImportError as exc:
        raise ImportError(
            "Couldn't import Django. Are you sure it's installed and "
            "available on your PYTHONPATH environment variable? Did you "
            "forget to activate a virtual environment?"
        ) from exc
    execute_from_command_line(sys.argv)
    # from django.urls import get_resolver, URLPattern, URLResolver
    # def get_all_url(resolver=None, pre='/'):
    #     if resolver is None:
    #         resolver = get_resolver()
    #     for r in resolver.url_patterns:
    #         if isinstance(r, URLPattern):
    #             if '<pk>' in str(r.pattern):
    #                 continue
    #             yield pre + str(r.pattern).replace('^', '').replace('$', ''), r.name
    #         if isinstance(r, URLResolver):
    #             yield from get_all_url(r, pre + str(r.pattern))
    #
    # for url, name in get_all_url():
    #     print("url='{}'  name='{}'".format(url, name))


if __name__ == '__main__':
    run.default_addr = '0.0.0.0'
    run.default_port = '8001'
    main()
